import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JLabel;
import javax.swing.Timer;


public class Main 
{
	static long startTime;
	static final long TIME_INCREMENT = 5;
	static final long GRAPHICS_INCREMENT = 15;
	public static void main(String[] args)
	{
		final World world = new World();
		world.add(new ParticlesComponent(world));
		world.setupPair();
		final boolean running = true;
		Timer timer = new Timer((int)GRAPHICS_INCREMENT, new ActionListener() {
			public void actionPerformed(ActionEvent ae)
			{
				world.repaint();
				world.validate();
				
			}
		});
		timer.start();
		Thread graphicsThread = new Thread(new Runnable()
		{
			public void run()
			{
				long startTime;
				while(running)
				{
					startTime = System.currentTimeMillis();
					world.repaint();
					world.validate();
					while(System.currentTimeMillis() - startTime < GRAPHICS_INCREMENT)
					{}
				}
				
			}
		});
		//graphicsThread.start();
		
		while(running)
		{
			world.incrementTime(TIME_INCREMENT);
			startTime = System.currentTimeMillis();
			while(System.currentTimeMillis() - startTime < TIME_INCREMENT)
			{}
		}
	}
	
	
}
